package ws.jdbc.concurrent.driver.sqlserver.tds.rpc;

/**
 * This class has the several numbers that identify the special
 * <a href="http://msdn.microsoft.com/en-us/library/ms187801.aspx">stored procedures</a>
 * that can be executed via RPC call.
 *
 * @author Wilson Santos, 36228 <wilson.santos@ua.pt>
 */
public final class StoredProcedures {

  /**
   * Requests positioned updates.
   *
   * <p>
   * <a href="http://msdn.microsoft.com/en-us/library/ff848759.aspx">Reference</a>
   * </p>
   */
  public static final short SP_CURSOR = 1;
  /**
   * Opens a cursor.
   *
   * <p>
   * <a href="http://msdn.microsoft.com/en-us/library/ff848737.aspx">Reference</a>
   * </p>
   */
  public static final short SP_CURSOROPEN = 2;
  /**
   * Prepares a parameterized Transact-SQL statement and returns a statement handle for execution.
   *
   * <p>
   * <a href="http://msdn.microsoft.com/en-us/library/ff848808.aspx">Reference</a>
   * </p>
   */
  public static final short SP_CURSORPREPARE = 3;
  /**
   * Creates and populates a cursor based upon the execution plan created by sp_cursorprepare.
   *
   * <p>
   * <a href="http://msdn.microsoft.com/en-us/library/ff848771.aspx">Reference</a>
   * </p>
   */
  public static final short SP_CURSOREXECUTE = 4;
  /**
   * Prepares and executes a parameterized Transact-SQL statement.
   *
   * <p>
   * <a href="http://msdn.microsoft.com/en-us/library/ff848812.aspx">Reference</a>
   * </p>
   */
  public static final short SP_CURSORPREPEXEC = 5;
  /**
   * Discards the execution plan created by the sp_prepare stored procedure.
   *
   * <p>
   * <a href="http://msdn.microsoft.com/en-us/library/ff848735.aspx">Reference</a>
   * </p>
   */
  public static final short SP_CURSORUNPREPARE = 6;
  /**
   * Fetches a buffer of one or more rows from the database.
   *
   * <p>
   * <a href="http://msdn.microsoft.com/en-us/library/ff848736.aspx">Reference</a>
   * </p>
   */
  public static final short SP_CURSORFETCH = 7;
  /**
   * Sets cursor options or returns cursor information created by the sp_cursoropen stored procedure.
   *
   * <p>
   * <a href="http://msdn.microsoft.com/en-us/library/ff848779.aspx">Reference</a>
   * </p>
   */
  public static final short SP_CURSOROPTION = 8;
  /**
   * Closes and de-allocates the cursor, as well as releases all associated resources.
   *
   * <p>
   * <a href="http://msdn.microsoft.com/en-us/library/ff848800.aspx">Reference</a>
   * </p>
   */
  public static final short SP_CURSORCLOSE = 9;
  /**
   * Prepares a parameterized Transact-SQL statement and returns a statement handle for execution.
   *
   * <p>
   * <a href="http://msdn.microsoft.com/en-us/library/ff848808.aspx">Reference</a>
   * </p>
   */
  public static final short SP_PREPARE = 11;
  /**
   * Executes a prepared Transact-SQL statement using a specified handle and optional parameter value.
   *
   * <p>
   * <a href="http://msdn.microsoft.com/en-us/library/ff848746.aspx">Reference</a>
   * </p>
   */
  public static final short SP_EXECUTE = 12;
  /**
   * Prepares and executes a parameterized Transact-SQL statement.
   *
   * <p>
   * <a href="http://msdn.microsoft.com/en-us/library/ff848812.aspx">Reference</a>
   * </p>
   */
  public static final short SP_PREPEXEC = 13;
  /**
   * Prepares and executes a parameterized stored procedure call that has been specified using an RPC identifier.
   *
   * <p>
   * <a href="http://msdn.microsoft.com/en-us/library/ff848753.aspx">Reference</a>
   * </p>
   */
  public static final short SP_PREPEXECRPC = 14;
  /**
   * Discards the execution plan created by the sp_prepare stored procedure.
   *
   * <p>
   * <a href="http://msdn.microsoft.com/en-us/library/ff848735.aspx">Reference</a>
   * </p>
   */
  public static final short SP_UNPREPARE = 15;

  /* --------------- sp_cursoropen SCROLLOPT PARAMETER VALUES ---------------- */
  public static final int SP_CURSOROPEN_SCROLLOPT_KEYSET = 0x0001;
  public static final int SP_CURSOROPEN_SCROLLOPT_DYNAMIC = 0x0002;
  public static final int SP_CURSOROPEN_SCROLLOPT_FORWARD_ONLY = 0x0004;
  public static final int SP_CURSOROPEN_SCROLLOPT_STATIC = 0x0008;
  public static final int SP_CURSOROPEN_SCROLLOPT_FAST_FORWARD = 0x10;
  public static final int SP_CURSOROPEN_SCROLLOPT_PARAMETERIZED_STMT = 0x1000;
  public static final int SP_CURSOROPEN_SCROLLOPT_AUTO_FETCH = 0x2000;
  public static final int SP_CURSOROPEN_SCROLLOPT_AUTO_CLOSE = 0x4000;
  public static final int SP_CURSOROPEN_SCROLLOPT_CHECK_ACCEPTED_TYPES = 0x8000;
  public static final int SP_CURSOROPEN_SCROLLOPT_KEYSET_ACCEPTABLE = 0x10000;
  public static final int SP_CURSOROPEN_SCROLLOPT_DYNAMIC_ACCEPTABLE = 0x20000;
  public static final int SP_CURSOROPEN_SCROLLOPT_FORWARD_ONLY_ACCEPTABLE = 0x40000;
  public static final int SP_CURSOROPEN_SCROLLOPT_STATIC_ACCEPTABLE = 0x80000;
  public static final int SP_CURSOROPEN_SCROLLOPT_FAST_FORWARD_ACCEPTABLE = 0x100000;

  /* ------------------ sp_cursoropen CCOPT PARAMETER VALUES ----------------- */
  public static final int SP_CURSOROPEN_CCOPT_READ_ONLY = 0x0001;
  public static final int SP_CURSOROPEN_CCOPT_SCROLL_LOCKS = 0x0002;
  public static final int SP_CURSOROPEN_CCOPT_OPTIMISTIC = 0x0004;
  //public static final int SP_CURSOROPEN_CCOPT_OPTIMISTIC = 0x0008;
  public static final int SP_CURSOROPEN_CCOPT_ALLOW_DIRECT = 0x2000;
  public static final int SP_CURSOROPEN_CCOPT_UPDT_IN_PLACE = 0x4000;
  public static final int SP_CURSOROPEN_CCOPT_CHECK_ACCEPTED_OPTS = 0x8000;
  public static final int SP_CURSOROPEN_CCOPT_READ_ONLY_ACCEPTABLE = 0x10000;
  public static final int SP_CURSOROPEN_CCOPT_SCROLL_LOCKS_ACCEPTABLE = 0x20000;
  public static final int SP_CURSOROPEN_CCOPT_OPTIMISTIC_ACCEPTABLE = 0x40000;
  //public static final int SP_CURSOROPEN_CCOPT_OPTIMISTIC_ACCEPTABLE = 0x80000;

  /* ------------- sp_cursorfetch FETCHTYPE PARAMETER VALUES ----------------- */
  /**
   * sp_cursorfecth fetchtype parameter: Fetches the first buffer of nrows rows.
   *
   * <p>
   * If nrows equals 0, the cursor is positioned before the result set and no rows are returned.
   * </p>
   */
  public static final int SP_CURSORFETCH_FETCHTYPE_FIRST = 0x0001;
  /**
   * sp_cursorfecth fetchtype parameter: Fetches the next buffer of nrows rows.
   */
  public static final int SP_CURSORFETCH_FETCHTYPE_NEXT = 0x0002;
  /**
   * sp_cursorfecth fetchtype parameter: Fetches the previous buffer of nrows rows.
   */
  public static final int SP_CURSORFETCH_FETCHTYPE_PREV = 0x0004;
  /**
   * sp_cursorfecth fetchtype parameter: Fetches the last buffer of nrows rows.
   *
   * <p>
   * If nrows equals 0, the cursor is positioned after the result set and no rows are returned.
   * </p>
   */
  public static final int SP_CURSORFETCH_FETCHTYPE_LAST = 0x0008;
  /**
   * sp_cursorfecth fetchtype parameter: Fetches a buffer of nrows rows starting with the rownum row.
   */
  public static final int SP_CURSORFETCH_FETCHTYPE_ABSOLUTE = 0x10;
  /**
   * sp_cursorfecth fetchtype parameter: Fetches the buffer of nrows rows starting with the row that is specified as being the rownum value of rows from the first row in the current block.
   *
   * <p>
   * In this case rownum can be a negative number.
   * </p>
   */
  public static final int SP_CURSORFETCH_FETCHTYPE_RELATIVE = 0x20;
  /**
   * sp_cursorfecth fetchtype parameter: Refills the buffer from underlying tables.
   */
  public static final int SP_CURSORFETCH_FETCHTYPE_REFRESH = 0x80;
  /**
   * sp_cursorfecth fetchtype parameter: Retrieves information about the cursor.
   *
   * <p>
   * This information is returned by using the rownum and nrows parameters.
   * Therefore, when INFO is specified, rownum and nrows become output parameters.
   * </p>
   */
  public static final int SP_CURSORFETCH_FETCHTYPE_INFO = 0x100;
  /**
   * Is used like PREV.
   *
   * <p>
   * However, if the top of the result set is encountered prematurely, the results might vary.
   * </p>
   */
  public static final int SP_CURSORFETCH_FETCHTYPE_PREV_NOADJUST = 0x200;
  /**
   * sp_cursorfecth fetchtype parameter: Must be used with one of the other fetchtype values, except for INFO.
   */
  public static final int SP_CURSORFETCH_FETCHTYPE_SKIP_UPDT_CNCY = 0x400;

  /* ----------------- sp_cursor OPTYPE PARAMETER VALUES --------------------- */
  /**
   * sp_cursor optype parameter value: Is used to update one or more rows in the 
   * fetch buffer.
   * 
   * <p>
   * The rows specified in rownum are re-accessed and updated.
   * </p>
   */
  public static final int SP_CURSOR_OPTYPE_UPDATE = 0x0001;
  /**
   * sp_cursor optype parameter value: Is used to delete one or more rows in the
   * fetch buffer.
   *
   * <p>
   * The rows specified in rownum are re-accessed and deleted.
   * </p>
   */
  public static final int SP_CURSOR_OPTYPE_DELETE = 0x0002;
  /**
   * sp_cursor optype parameter value: Inserts data without building an INSERT
   * statement.
   */
  public static final int SP_CURSOR_OPTYPE_INSERT = 0x0004;
  /**
   * sp_cursor optype parameter value: Is used to refill the buffer from underlying
   * tables and can be used to refresh the row if an update or delete fails due
   * to optimistic concurrency control, or after an UPDATE.
   *
   * <p>
   * The rows specified in rownum are re-accessed and deleted.
   * </p>
   */
  public static final int SP_CURSOR_OPTYPE_REFRESH = 0x0008;
  /**
   * sp_cursor optype parameter value: Causes a SQL Server U-Lock to be acquired
   * on the page containing the specified row.
   *
   * <p>
   * This lock is compatible with S-Locks but not with X-Locks or other U-Locks.
   * Can be used to implement short-term locking.
   * </p>
   */
  public static final int SP_CURSOR_OPTYPE_LOCK = 0x10;
  /**
   * Is used only when the program is going to issue a subsequent SQL Server
   * positioned DELETE or UPDATE statement.
   */
  public static final int SP_CURSOR_OPTYPE_SETPOSITION = 0x20;
  /**
   * sp_cursor optype parameter value: Can only be used in conjunction with
   * UPDATE or DELETE.
   *
   * <p>
   * ABSOLUTE is used only with KEYSET cursors. It is ignored for DYNAMIC cursors
   * and STATIC cursors cannot be updated.
   * </p>
   */
  public static final int SP_CURSOR_OPTYPE_ABSOLUTE = 0x40;

  /**
   * Prevent instantiation.
   */
  private StoredProcedures() {
  }
}
